<script setup>
import {ref} from "vue";
import {http} from "@/api";

const nodeList = ref([])
http.system.list().then(res => {
  nodeList.value = res.data
})
</script>

<template>
  <PageMain title="系统图">
    <div class="canvas">
      <div class="floor1">
        <div class="node1">
          电网调度中心
        </div>
        <div class="node2">
          <div class="node-text">发电控制器</div>
          <img src="@/assets/node2.png" alt="">
        </div>
        <div class="node3">
          <div class="node-text">气象站</div>
          <img src="@/assets/node3.png" alt="">
        </div>
        <div class="node-text2">优化工作站</div>
        <div class="node4">
          <img src="@/assets/node4.png" alt="">
        </div>
        <div class="node5">
          <img src="@/assets/node4.png" alt="">
        </div>
        <div class="node6">
          <img src="@/assets/node4.png" alt="">
        </div>
        <div class="node7">
          <img src="@/assets/node4.png" alt="">
        </div>
        <div class="node8">
          <div class="node-text">数据发送工作站</div>
          <img src="@/assets/node4.png" alt="">
        </div>
        <div class="node9">
          <div class="node-text">工程师站</div>
          <img src="@/assets/node9.png" alt="">
        </div>
        <div class="node10">
          <div class="node-text">操作员站</div>
          <img src="@/assets/node9.png" alt="">
        </div>
      </div>
      <div class="floor2">
        <div class="node-text">主交换机</div>
        <div class="line"></div>
      </div>
      <div class="floor3">
        <div class="node-text">数据采集防火墙</div>
        <div class="line"></div>
      </div>
      <div class="floor4">
        <div class="node-text">控制电缆</div>
        <div class="line"></div>
      </div>
      <div class="floor5">
<!--        <div class="node-custom-tips1">数据通道故障</div>-->
<!--        <div class="node-custom-tips2">网络正常</div>-->
        <div :class="['node-custom node' + (10 + index + 1)]" v-for="(item,index) in nodeList" :key="item.id">
          <img :src="item.image_url" alt="">
          <div class="node-text">{{ item.name }}</div>
          <div class="node-text">{{ item.status }}</div>
        </div>
      </div>
    </div>
  </PageMain>
</template>

<style scoped lang="scss">
:deep(.el-card__body) {
  background-color: #999;
  font-size: 14px;
}
.node-text {
  font-size: 14px;
  color: #FFFFFF;
  margin-bottom: 5px;
}
.floor2 {
  width: 100%;
  position: absolute;
  left: 0px;
  top: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  .line {
    width: 100%;
    height: 2px;
    background-color: #0067D1;
  }
}
.floor3 {
  width: 100%;
  position: absolute;
  left: 0px;

  top: 250px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  .line {
    width: 100%;
    height: 2px;
    background-color: darkred;
  }
}
.floor4 {
  width: 100%;
  position: absolute;
  left: 0px;

  top: 300px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  .line {
    width: 100%;
    height: 2px;
    background-color: yellow;
  }
}
.canvas {
  position: relative;
  width: 850px;
  height: 580px;
  margin: 0 auto;
}
.node1 {
  position: absolute;
  background-color: #FFFFFF;
  padding: 5px 10px;
  border-radius: 4px;
  left: 0px;
  top: 0;
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 100px;
    background-color: #0067D1;
    z-index: 0;
  }
}
.node2 {
  position: absolute;
  top: 100px;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 120px;
    height: 40px;
  }
  .node-text {
    margin-right: 5px;
    color: #FFFFFF;
  }
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 62px;
    background-color: #0067D1;
    z-index: 0;
  }
  &::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 20%;
    width: 2px;
    height: 166px;
    background-color: yellow;
    z-index: 0;
  }
}
.node3 {
  position: absolute;
  top: 55px;
  left: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 50px;
    height: 80px;
  }
  .node-text {
    margin-bottom: 5px;
    color: #FFFFFF;
  }
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 66px;
    background-color: #0067D1;
    z-index: 0;
  }
}
.node-text2 {
  position: absolute;
  top: 77px;
  left: 324px;
  color: #FFFFFF;
}
.node4,
.node5,
.node6,
.node7{
  position: absolute;
  top: 109px;
  left: 281px;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 20px;
    height: 50px;
  }
  .node-text {
    margin-bottom: 5px;
    color: #FFFFFF;
  }
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 66px;
    background-color: #0067D1;
    z-index: 0;
  }
}
.node5 {
  left: 324px
}
.node6 {
  left:368px
}
.node7 {
   left:412px
 }
.node8{
  position: absolute;
  top: 77px;
  left: 469px;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 20px;
    height: 50px;
  }
  .node-text {
    margin-bottom: 12px;
    color: #FFFFFF;
  }
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 66px;
    background-color: #0067D1;
    z-index: 0;
  }
  &::before {
    content: '';
    position: absolute;
    top: 100%;
    right:40px;
    width: 2px;
    height: 116px;
    background-color: darkred;
    z-index: 0;
  }
}
.node9{
  position: absolute;
  top: 77px;
  left: 615px;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 50px;
    height: 50px;
  }
  .node-text {
    margin-bottom: 12px;
    color: #FFFFFF;
  }
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 66px;
    background-color: #0067D1;
    z-index: 0;
  }
}
.node10{
  position: absolute;
  top: 77px;
  left: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 50px;
    height: 50px;
  }
  .node-text {
    margin-bottom: 12px;
    color: #FFFFFF;
  }
  &::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    width: 2px;
    height: 66px;
    background-color: #0067D1;
    z-index: 0;
  }
}
.node-custom-tips {
  position: absolute;
  top: 400px;
  left: 60px;
}
.node-custom{
  position: absolute;
  top: 400px;
  left: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 50px;
    height: 50px;
    margin-bottom: 6px;
  }
  .node-text {
    color: #FFFFFF;
  }
  &::before {
    content: '';
    position: absolute;
    left: 20%;
    bottom: 100%;
    width: 2px;
    height: 76px;
    background-color: yellow;
    z-index: 0;
  }
  &::after {
    content: '';
    position: absolute;
    left: 60%;
    bottom: 100%;
    width: 2px;
    height: 126px;
    background-color: darkred;
    z-index: 0;
  }
}
.node12 {
  left: 160px;
}
.node13 {
  left: 260px;
}
.node14 {
  left: 360px;
}
.node15 {
  left: 460px;
}
.node16 {
  left: 660px;
}</style>